﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace Solidi
{
	class ListDependencyFactory<T> : GenericDependencyFactory
	{
		public override object Create(IDependencyContext context, IDependencyKey key)
		{
			IList list = new List<T>();

			foreach (IDependency dependency in context.Registry.Find(key))
			{
				object element = context.Lifetime.Resolve(context, dependency);

				if (element != null)
				{
					list.Add(element);
				}
			}

			if (list.Count > 0)
			{
				return list;
			}

			return null;
		}
	}
}
